package array;

/**
 * @Author wangtengyu
 * @Date 2019/9/21 7:21 PM
 * @Description 字符串转整数
 */
public class StringtoInt {



public static void main(String args[]){
  StringtoInt stringtoInt=new StringtoInt();
  System.out.println(stringtoInt.StrToInt("-1234567"));
  System.out.println(stringtoInt.test());

}


private int StrToInt(String str){
  int flag=0;
  if (str.charAt(0)=='+'){
    flag=1;
  }
  if (str.charAt(0)=='-'){
    flag=2;
  }
  int start=flag>0?1:0;
  int result=0;
  for (int i=start;i<str.length();i++){
    int temp=str.charAt(i)-'0';
    result=10*result+temp;
  }
  return flag<2?result:-result;

}


private int test(){
  char a='1';
  return a-'0';
}



}
